﻿Imports System.Data.SqlClient
Imports Bussines.entity
Imports System.Xml

Public Class equiposDAL
    Private conexion As New conexion
    Public Function listarEquipos() As DataTable
        Dim dt As New DataTable
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "sp_listarEquipos"
        Try
            cmd.Connection = conexion.abrir()
            dt.Load(cmd.ExecuteReader())
            cmd.Dispose()
            conexion.Cerrar()
            Return dt
        Catch ex As Exception
            Return dt
        Finally

        End Try
    End Function

    Public Function listar_GruposSharepointXIdEquipo(ByVal equipo_id As String) As DataTable
        Dim dt As New DataTable
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "pdo_listar_GruposSharepointXIdEquipo"
        cmd.Parameters.Add(New SqlParameter("@equipo_id", SqlDbType.VarChar)).Value = equipo_id
        Try
            cmd.Connection = conexion.abrir()
            dt.Load(cmd.ExecuteReader())
            cmd.Dispose()
            conexion.Cerrar()
            Return dt
        Catch ex As Exception
            Return dt
        Finally

        End Try
    End Function



    Public Function recuperarGrupoIntegrante(ByVal idEquipo As String) As String
        Dim dt As New DataTable
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "pdo_sp_listarGrupoIntegrante"
        cmd.Parameters.Add(New SqlParameter("@equipo_id", SqlDbType.VarChar)).Value = idEquipo
        Try
            cmd.Connection = conexion.abrir()
            Dim strGrupo As String = cmd.ExecuteScalar.ToString()
            cmd.Dispose()
            conexion.Cerrar()
            Return strGrupo
        Catch ex As Exception
            Return Nothing
        Finally

        End Try

    End Function

    Public Function recuperarGrupoModeradores(ByVal idEquipo As String) As String
        Dim dt As New DataTable
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "pdo_sp_listarGrupoModerador"
        cmd.Parameters.Add(New SqlParameter("@equipo_id", SqlDbType.VarChar)).Value = idEquipo
        Try
            cmd.Connection = conexion.abrir()
            Dim strGrupo As String = cmd.ExecuteScalar.ToString()
            cmd.Dispose()
            conexion.Cerrar()
            Return strGrupo
        Catch ex As Exception
            Return Nothing
        Finally

        End Try

    End Function

    Public Function BuscarEmpleadosMasa(ByVal Documento As XmlDocument) As DataTable
        Dim dt As New DataTable
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "pdo_sp_listarIntegrantes"
        cmd.Parameters.Add(New SqlParameter("@DocumentoXML", SqlDbType.VarChar, -1)).Value = Documento.InnerXml
        Try
            cmd.Connection = conexion.abrir()
            dt.Load(cmd.ExecuteReader())
            cmd.Dispose()
            conexion.Cerrar()
            Return dt
        Catch ex As Exception
            Return Nothing
        Finally

        End Try

    End Function


End Class
